package demo.oo.trains;

import java.util.ArrayList;
import java.util.List;

/**
 * SimpleRoute is the route connect two cities directly. No other city on this
 * route.
 * 
 * @author lifany
 * 
 */
public class Edge extends Route {
	private int length;
	private List<Edge> nextEdges = new ArrayList<Edge>();

	public Edge(String startPoint, String endPoint, int length) {
		this.startPoint = startPoint;
		this.endPoint = endPoint;
		this.length = length;
	}

	@Override
	public int getLength() {
		return length;
	}

	public List<Edge> getNextEdges() {
		return nextEdges;
	}

	public void setNextEdges(List<Edge> nextEdges) {
		this.nextEdges = nextEdges;
	}

	@Override
	public String toString() {
		return "Edge: " + startPoint + endPoint + length;
	}

	@Override
	public int hashCode() {
		return startPoint.hashCode() * 3 + endPoint.hashCode() * 2;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null || !(obj instanceof Edge))
			return false;

		Edge route = (Edge) obj;
		return route.getStartPoint().equals(startPoint) && route.getEndPoint().equals(endPoint);
	}

}
